dados = csvread('movies/donkey_dbt.csv');
x = dados(:,1);
y = dados(:,2);
[p,s] = polyfit(x, y, 20);
q = polyder(p);
r = polyder(q);
f = polyval(p,x);
g = polyval(q,x);
h = polyval(r,x);
fig = figure('visible', 'off');

plot(f);
title('Cycles over time');
xlabel('Time (s)');
ylabel('Accumulated Cycles');
print(fig, '-dpng', '-color' , 'figs/pos/position.png');

plot(g);
title('Velocity');
xlabel('Time (s)');
ylabel('Cycles/s');
print(fig, '-dpng', '-color', 'figs/vel/velocity.png');

plot(h);
title('Acceleration');
xlabel('Time (s)');
ylabel('Cycles/s^2');
print(fig, '-dpng', '-color', 'figs/acc/acceleration.png');

